<template>
  <div class="navbar">
    <navbar>
        <template v-slot:left>
            <img src="~assets/img/common/back.svg" alt="" class="back" @click="backClick">
        </template>
        <template v-slot:center>
            <div class="title">
                <div v-for="(item,index) in titles" 
                    :key="index"
                    class="title-item"
                    :class="{active:index === currentIndex}"
                    @click="titleClick(index)">
                        {{item}}
                </div>
            </div>
        </template>
    </navbar>
  </div>
</template>

<script>
import navbar from 'components/common/navbar/navbar.vue'
export default {
    name:'detailnavbar',
    components:{
        navbar
    },
    data(){
        return {
            titles:['商品','参数','评论','推荐'],
            currentIndex:0
        }
    },
    methods:{
        titleClick(index){
            this.currentIndex = index
			this.$emit('titleClick',index)
        },
        backClick(){
            this.$router.back()
        }
    }
}
</script>

<style scoped>
	.navbar {
		background-color: #fff;
	}
    .title {
        display: flex;
        font-size: 11px;
        margin-top: 0;
    }
    .title-item {
        flex: 1;
    }
    .active {
        color: var(--color-high-text);
    }
    .back {
        margin-top: 11px;
    }
</style>